<?php

$_this =& $this;

/* @var $_this View */
/* @var $form FormHelper */
/* @var $editForm EditFormHelper */
/* @var $html HtmlHelper */
/* @var $ehtml EHtmlHelper */
/* @var $javascript JavascriptHelper */
/* @var $jqax JqaxHelper */
/* @var $filterBlock FilterBlock */

?><?=$editForm->create($modelName, array('url'=>("/{$url_part}/".$this->data[$modelName][$PKName].'/'), 'allowInput' => $this->data[$modelName]['__allows']['update']));?><?php

	?><?=$editForm->startSet();?><?php
		?><?=$editForm->textView(__d($po_domain, 'entity_name', true), $this->data[$modelName]["surname"].' / '.$this->data[$modelName]["name"]);?><?php
		?><?=$editForm->textView(__d($po_domain, 'group', true), $this->data['Group']["name"]);?><?php
		?><?=$editForm->datetimeView(__d($po_domain, 'created_field', true), $this->data[$modelName]["created"]);?><?php
		/*
		?><?=$editForm->field("select_tool", __d($po_domain, 'select_tool', true), $form->select("select_tool", $tools_list, null, array('required' => true, 'vertical' => false), __d(null, 'enum_all', true)));?><?php
		?><?=$editForm->field("test_group", __d($po_domain, 'test_group', true), $form->select("test_group", $test_groups_list, null, array('required' => true, 'vertical' => false), __d(null, 'enum_all', true)));?><?php
		*/
	?><?=$editForm->endSet();?><?php

	ob_start();

if (count($completed_tests_list)) {

?><table class="table" cellpadding="0"><?php
?><thead><?php
    ?><tr><?php
        ?><th class="nw"><?php
            ?><?=__d('tests', 'name', true);?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=__d('tests', 'type', true);?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=__d($po_domain, 'test_pass_date', true);?><?php
        ?></th><?php
    ?></tr><?php
?></thead><?php
?><tbody><?php

    $i = 0;
    foreach ($completed_tests_list as $item) {
        $class = '';
    	if ($i++ % 2 != 0) {
    		$sep = strlen($class) ? ' ' : '';
    		$class .= $sep.'altrow';
    	}
    	$class = strlen($class) ? ' class="'.$class.'"' : '';

        ?><tr <?=$class;?>><?php
    		?><td class="nw"><?php
                ?><?=$item['Test']['name'];?><?php
            ?></td><?php
    		?><td class="nw"><?php
                ?><?=__d('tests', 'type_'.$item['Test']['type'], true);?><?php
            ?></td><?php
    		?><td class="nw"><?php
                ?><?=Date::Short(Date::SQL2UNIX($item['Testing']['pass_date']));?><?php
            ?></td><?php
    	?></tr><?php
    }

?></tbody><?php
?></table><?php

} else {
    ?><span class="additional_msg"><?php
        ?><?=__d($po_domain, 'Completed test list is empty', true);?><?php
    ?></span><?php
}
	$content = ob_get_clean();

	?><?=$editForm->header(__d($po_domain, 'Completed test list header', true));?><?php
	?><?=$editForm->cell($content, array('class' => 'non-top-margin'));?><?php


		ob_start();

if (count($appointed_tests_list)) {

?><table class="table" cellpadding="0"><?php
?><thead><?php
    ?><tr><?php
        ?><th class="nw"><?php
            ?><?=__d('tests', 'name', true);?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=__d('tests', 'type', true);?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=__d('testings', 'link', true);?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=__d('testsing', 'password', true);?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=__d('tests', 'price', true);?><?php
        ?></th><?php
        ?><th class="actions nw"></th><?php
    ?></tr><?php
?></thead><?php
?><tbody><?php

    $i = 0;
    foreach ($appointed_tests_list as $item) {
        $class = '';
    	if ($i++ % 2 != 0) {
    		$sep = strlen($class) ? ' ' : '';
    		$class .= $sep.'altrow';
    	}
    	$class = strlen($class) ? ' class="'.$class.'"' : '';

        ?><tr <?=$class;?>><?php
    		?><td class="nw"><?php
                ?><?=$item['Test']['name'];?><?php
            ?></td><?php
    		?><td class="nw"><?php
                ?><?=__d('tests', 'type_'.$item['Test']['type'], true);?><?php
            ?></td><?php
            ?><td class="nw"><?php
            	$url = array('controller' => 'applet' , 'action' => 'go', 'auth' => $item['Testing']['auth_link']);
                ?><?=$html->link(__d($po_domain, 'Start test link', true) , $url, array(), __d('tests', 'Are you sure you want to go to the start test page? You will be logged out then', null) );?><?php
            ?></td><?php
    		?><td class="nw"><?php
                ?><?=$item['Testing']['password']?><?php
            ?></td><?php
    		?><td class="nw align-r"><?php
                ?><?=$this->renderElement('amount', array('amount' => $item['Test']['price_test'], 'currency' => 'EP'));?><?php
            ?></td><?php
            ?><td class="actions nw"><?php
                ?><table class="sys_clear" cellpadding="0"><?php
                ?><tr class="sys_clear"><?php
                    ?><?=$ehtml->iconLink("edit", __d(null, 'details', true), "/candidates/{$this->data[$modelName][$PKName]}/tools/appointed/{$item['Testing']['id']}");?><?php
                    $inactive = empty($item['Testing']['__allows']['cancel']);
                    $inactive_str = $inactive ? __d($po_domain, 'You can’t cancel this tool', true) : false;
                    ?><?=$ehtml->iconLink("cancel", __d(null, 'Cancel', true), "/candidates/{$this->data[$modelName][$PKName]}/tools/cancel/{$item['Testing']['id']}", array('inactive' => $inactive_str), __d('tests', 'Are you sure you want to cancel of this test?', true));?><?php
                ?></tr><?php
                ?></table><?php
            ?></td><?php
    	?></tr><?php
    }

?></tbody><?php
?></table><?php

} else {
    ?><span class="additional_msg"><?php
        ?><?=__d($po_domain, 'Appointed test list is empty', true);?><?php
    ?></span><?php
}
	$content = ob_get_clean();

	?><?=$editForm->header(__d($po_domain, 'Appointed test list header', true));?><?php
	?><?=$editForm->cell($content, array('class' => 'non-top-margin'));?><?php

		ob_start();

if (count($in_progress_tests_list)) {

?><table class="table" cellpadding="0"><?php
?><thead><?php
    ?><tr><?php
        ?><th class="nw"><?php
            ?><?=__d('tests', 'name', true);?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=__d('tests', 'type', true);?><?php
        ?></th><?php
        ?><th class="actions nw"></th><?php
    ?></tr><?php
?></thead><?php
?><tbody><?php

    $i = 0;
    foreach ($in_progress_tests_list as $item) {
        $class = '';
    	if ($i++ % 2 != 0) {
    		$sep = strlen($class) ? ' ' : '';
    		$class .= $sep.'altrow';
    	}
    	$class = strlen($class) ? ' class="'.$class.'"' : '';

        ?><tr <?=$class;?>><?php
    		?><td class="nw"><?php
                ?><?=$item['Test']['name'];?><?php
            ?></td><?php
    		?><td class="nw"><?php
                ?><?=__d('tests', 'type_'.$item['Test']['type'], true);?><?php
            ?></td><?php
    		?><td class="actions nw"><?php
                ?><table class="sys_clear" cellpadding="0"><?php
                ?><tr class="sys_clear"><?php
                    $inactive = empty($item['Testing']['__allows']['cancel']);
                    $inactive_str = $inactive ? __d($po_domain, 'You can’t cancel this tool', true) : false;
                    ?><?=$ehtml->iconLink("cancel", __d(null, 'Stop', true), "/candidates/{$this->data[$modelName][$PKName]}/tools/cancel/{$item['Testing']['id']}", array('inactive' => $inactive_str), __d('tests', 'Are you sure you want to stop progressing of this test? This might be unsafe action.', true));?><?php
                    ?><?=$ehtml->iconLink("edit", __d('testings', 'enter_result_title', true), array('controller' => 'testings', 'action' => 'enter_result', 'candidate_id' => $this->data[$modelName][$PKName], 'testing_id' => $item['Testing']['id']));?><?php
                ?></tr><?php
                ?></table><?php
            ?></td><?php
    	?></tr><?php
    }

?></tbody><?php
?></table><?php

} else {
    ?><span class="additional_msg"><?php
        ?><?=__d($po_domain, 'In progress tool list is empty', true);?><?php
    ?></span><?php
}
	$content = ob_get_clean();

	?><?=$editForm->header(__d($po_domain, 'Tools in progress', true));?><?php
	?><?=$editForm->cell($content, array('class' => 'non-top-margin'));?><?php


	ob_start();

if (count($tests_list)) {

?><table class="table" cellpadding="0"><?php
?><thead><?php
    ?><tr><?php
        ?><th class="nw"><?php
            ?><?=__d('tests', 'name', true);?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=__d('tests', 'type', true);?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=__d('tests', 'price', true);?><?php
        ?></th><?php
        ?><th class="actions nw"></th><?php
    ?></tr><?php
?></thead><?php
?><tbody><?php

    $i = 0;
    foreach ($tests_list as $item) {
        $class = '';
    	if ($i++ % 2 != 0) {
    		$sep = strlen($class) ? ' ' : '';
    		$class .= $sep.'altrow';
    	}
    	$class = strlen($class) ? ' class="'.$class.'"' : '';

        ?><tr <?=$class;?>><?php
    		?><td class="nw"><?php
                ?><?=$item['Test']['name'];?><?php
            ?></td><?php
    		?><td class="nw"><?php
                ?><?=__d('tests', 'type_'.$item['Test']['type'], true);?><?php
            ?></td><?php
    		?><td class="nw align-r"><?php
                ?><?=$this->renderElement('amount', array('amount' => $item['Test']['price_test'], 'currency' => 'EP'));?><?php
            ?></td><?php
            ?><td class="actions nw"><?php
                ?><table class="sys_clear" cellpadding="0"><?php
                ?><tr class="sys_clear"><?php
                    $inactive = empty($item['Test']['__allows']['apply']);
                    $inactive_str = $inactive ? __d($po_domain, 'You don’t apply this tool', true) : false;
                    $sum_txt = $editForm->drawAmountTXT($item['Test']['price_test'], 'EP');
                    $confirm = sprintf(__d('candidates', 'appoint_confirm'.(Auth::o()->is('admin') ? '_for_admin' : ''), true), $sum_txt);
                    ?><?=$ehtml->iconLink("add", __d('candidates', 'apply_tool', true), "/candidates/{$this->data[$modelName][$PKName]}/tools/apply/{$item['Test']['id']}", array('inactive' => $inactive_str), $confirm);?><?php
                ?></tr><?php
                ?></table><?php
            ?></td><?php
    	?></tr><?php
    }

?></tbody><?php
?></table><?php

} else {
    ?><span class="additional_msg"><?php
        ?><?=__d($po_domain, 'For apply test list is empty', true);?><?php
    ?></span><?php
}

	$content = ob_get_clean();

	?><?=$editForm->header(__d($po_domain, 'For apply test list header', true));?><?php
	?><?=$editForm->cell($content, array('class' => 'non-top-margin'));?><?php

	$buttonsHTML = '';
	$buttonsHTML .= (strlen($buttonsHTML) ? ' ' : '').$editForm->back("/{$url_part}/");
	if (strlen($buttonsHTML)) {
    	?><?=$editForm->cell($buttonsHTML);?><?php
	}

?><?=$editForm->end();?><?php

?>
